<?php
include 'connection.php';
$result = mysql_query("select count(id) from advertisement");
$row=mysql_fetch_row($result);
$columns='';
$values='"';
$setvalue='';
foreach($_POST as $column=>$value)
{
	$columns .=$column.',';
	$values .=$value.'",';
	$setvalue .=$column.'="'.$value.'" ,';
}
$columns=trim($columns,',');
$values=trim($values,',');
$setvalue=trim($setvalue,',');
if($row[0])
{
	$sql='UPDATE advertisement SET '.$setvalue;
	//echo $sql;exit;
}else
{
	$sql='insert into advertisement ('.$columns.') values('.$values.')';
}
$save_result=mysql_query($sql);
if(!$save_result)
{
	echo '0';
}else{
echo '1';
}
?>